<!--
  移动签批->公文详情->发文->签发
-->
<template>
	<view>
		<van-popup v-model="showCompo" closeable round position="bottom" :style="{ height: '80%' }"
			@click-close-icon="toClose" @click-overlay="toClose">
			<van-row type="flex" justify="center">
				<van-col offset="3" span="8">
					<van-cell value="签发" />
				</van-col>
			</van-row>
			<van-form @submit="onSubmit">
					<!-- <view class="cu-form-group align-start">
						<textarea class="textarea"  maxlength="-1" :rules="[{ required: true, message: '请填写意见' }]"  placeholder="请填写签发意见" v-model="qfopinion"></textarea>
					</view> -->
					<van-cell-group inset>
				<!-- 	<van-field
						v-model="qfopinion"
						rows="2"
						autosize
						type="textarea"
						placeholder="请输入"
						clearable
						:rules="[{ required: true, message: '请填写意见' }]"
					  /> -->
					    <van-field
					      v-model="qfopinion"
					      rows="6"
					      autosize
						  label="签发意见"
					      type="textarea"
					      maxlength="150"
						  show-word-limit
						  clearable
					      placeholder="请输入签发意见"
						  :rules="[{ required: true, message: '内容不能为空' }]"
					    />
					</van-cell-group>
				<view class="css">
					<van-row type="flex" justify="space-around">
						<van-col span="10">
							<van-button type="info" round plain hairline block @click.prevent="toClose">取消</van-button>
						</van-col>
						<van-col span="10">
							<van-button type="info" round block  native-type="submit">确定</van-button>
						</van-col>
					</van-row>
				</view>
			</van-form>
		</van-popup>
	</view>
</template>

<script>
	import Toast from 'vant';
	export default {
		components: {},
		props: {
			showIssuance: {
				type: Boolean,
				default: false
			},
			//{"bizId":"26c01daaf42448b68e0a540a42fb9cf3","proInstId":"01aead9032f240e6812c259af6cc9323","configId":"2d3327240f0f41c9843ac1c809e64a95","proDirId":"d41474fb261647528cf4d7f16d47af4d","actInstId":"2193cd4a7ade4f2f8f7dc4e9b56183ef","actDefId":"otherTask","workitemId":"c0d1b21c0ef54c5a96de28953d1d1dd8","state":null,"isClosed":"2","configCode":"glj_fw"}
			paramObject:{
				type: Object
			}
		},
		watch: {
			showIssuance(val){
				this.showCompo = val
			},
		},
		data() {
			return {
				showCompo:false,//组件是否显示
				qfopinion:'',//签发意见
			}
		},
		mounted() {
			this.$nextTick(function(){
				console.log("paramObject: " + JSON.stringify(this.paramObject));
			})
		},
		methods: {

			onSubmit() {
				this.saveopinion()
				this.$emit('closeIssuance', this.showIssuance);
			},
			toClose() {
				this.$emit('closeIssuance', this.showIssuance);
			},

			//签发
			saveopinion(){
				var _this = this
				this.$httploading({
				  url: this.$http.adornUrl(`/caac/oa/component/approval/saveopinion?systemKey=`+this.cache.get('userInfo').systemKey+`&systemFlag=`+this.cache.get('userInfo').systemFlag),
				  method: 'post',
				  data: this.$http.adornData({
					  'actInstId': this.paramObject.actInstId,//
					  'isApproval':'1',//核稿状态，默认传1
					  'opinion':this.qfopinion,
					  'opiniontype':'jldReview',//
					  'proInstId': this.paramObject.proInstId,//发文详情返回的proInstId
					  'workItemId': this.paramObject.workitemId//
					  // 'systemKey': 'jb_sun',//固定值
					  // 'systemFlag': 'yidong',//固定值
				  })
				}).then(({data}) => {
					console.log("签发：data-->: " + JSON.stringify(data));
					if(data.code==200){
						//通知父页面重新加载数据
						_this.qfopinion=''//成功后清空
						_this.$emit('refreshBtnGroup',true)//通知父组件重新加载数据
					}else{
						console.log("签发失败--data: " + JSON.stringify(data));
					}

				})
			},
		},
	};
</script>

<style scoped>
	.cu-form-group{
		border: 2rpx solid #e4e4e4;
		border-radius: 10rpx;
	}
	.textarea{
		margin: 32rpx 0 30rpx;
		height: 300rpx;
		width: 100%;
		line-height: 40rpx;
		-webkit-box-flex: 1;
		-webkit-flex: 1;
		flex: 1;
		font-size: 32rpx;
		padding: 0;


	}
	.css {
		text-align: center;
		position: fixed;
		left: 0;
		right: 0;
		bottom: 3%;
	}

	/deep/ .van-cell__title {
		min-width: 20%;

		span {
			display: inline-block;
			text-align: left;
			word-break: break-all;
		}
	}


</style>
